package com.yuwei.service;

import com.yuwei.bean.Menus;
import com.yuwei.bean.MenusData;
import com.yuwei.bean.Meta;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

@Service
public class HomeService {
    private Menus menus = new Menus();

    /**
     *
     * @param menuName 菜单显示的名称(中文名称)
     * @param name     英文名称
     * @param id
     */
    private MenusData createMenu(String menuName, String name, int id)
    {
        MenusData top = new MenusData();
        top.setId(id);
        top.setAuthName(menuName);
        top.setPath(name);
        return top;
    }

    private void addUserMgr()
    {
        MenusData userMgr = createMenu("用户管理","users",101);
        menus.addMenusData(userMgr);

        MenusData user =createMenu("用户列表","users",1011);
        userMgr.addMenusData(user);
    }

    private void addRightMgr()
    {
        MenusData rightMgr = createMenu("权限管理","rights",102);
        menus.addMenusData(rightMgr);

        MenusData role = createMenu("角色列表","roles",1021);
        rightMgr.addMenusData(role);

        MenusData right =createMenu("权限列表","rights",1022);
        rightMgr.addMenusData(right);

    }

    private void addGoodsMgr()
    {
        MenusData goodsMgr = createMenu("商品管理","goods",103);
        menus.addMenusData(goodsMgr);

        MenusData good = createMenu("商品列表","good",1031);
        goodsMgr.addMenusData(good);

        MenusData param = createMenu("分类参数","good",1032);
        goodsMgr.addMenusData(param);

        MenusData fen = createMenu("商品分类","good",1033);
        goodsMgr.addMenusData(fen);
    }

    private void addOrder()
    {
        MenusData ordersMgr = createMenu("订单管理","orders",104);
        menus.addMenusData(ordersMgr);

        MenusData ordersList = createMenu("订单列表","order",1041);
        ordersMgr.addMenusData(ordersList);
    }

    private void addStaticInfo()
    {
        MenusData StaticInfo = createMenu("数据统计","staticInfo",105);
        menus.addMenusData(StaticInfo);
    }

    private void addMeta()
    {
        Meta meta = new Meta();
        menus.setMeta(meta);
        meta.setMsg("获取菜单列表成功");
        meta.setStatus(200);
    }

    public Menus getMenus() {
        return menus;
    }

    @PostConstruct
    public void init()
    {
        addUserMgr();
        addRightMgr();
        addGoodsMgr();
        addOrder();
        addStaticInfo();
        addMeta();
    }
}
